<?php

namespace app\common\model;

use think\Model;

/**
 * 会员余额日志模型
 */
class MoneyLog Extends Model
{

    /**
     * 1=系统奖励
     */
    const TYPE_SYSTEM = 1;

    /**
     * 2=下级发广告奖励
     */
    const TYPE_TEAM_AD = 2;

     /**
     * 3=下级下单奖励,4=看广告奖励
     */
    const TYPE_TEAM_ORDER = 3;

    /**
     * 4=看广告奖励
     */
    const TYPE_VIEW_AD = 4;

    /**
     * 5=下级看广告得赏金奖励
     */
    const TYPE_TEAM_GOLD_AD = 5;


    // 表名
    protected $name = 'user_money_log';
    // 开启自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = '';
    // 追加属性
    protected $append = [
        'createtime_text'
    ];


    public function getTypeList()
    {
        return ['1' => "系统", '2' => "下级发广告奖励", "3" => "下级下单奖励", "4" => "看广告奖励", "5" => "下级看广告得赏金奖励"];
    }

    public function getTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
        $list = $this->getTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function getCreatetimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['createtime']) ? $data['createtime'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }


}
